package com.da.javatest.niuke.baodian;

/**
 * @author chenlida
 * @date 2020/10/12 10:56
 * https://www.nowcoder.com/practice/3afe6fabdb2c46ed98f06cfd9a20f2ce?tpId=8&tags=&title=&diffculty=0&judgeStatus=0&rp=1
 */
public class C56Finder {
    public int[] findElement(int[][] mat, int n, int m, int x) {
        for (int i = 0; i < n; i++) {
            if (x >= mat[i][0] && x <= mat[i][m - 1]) {
                for (int j = 0; j < m; j++) {
                    if (mat[i][j] == x) {
                        return new int[] {i, j};
                    }
                }
            }
        }
        return new int[] {n, m};
    }
}
